﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace WIAssistant
{
    /// <summary>
    /// This class wraps the <see cref="FieldDefinition"/> for the source mapped field.
    /// </summary>
    public class SourceField
    {
        
        public SourceField(FieldDefinition sourceField, FieldDefinitionCollection destFields, 
            WorkItemMappingMade onMappingMade, WorkItemMappingFailed onMappingFailed)
        {
            SrcField = sourceField;
            DropTarget = new DestinationFieldDropTargetAdvisor(SrcField, destFields, onMappingMade, onMappingFailed);
            
            DragSource = new DestinationFieldDragSourceAdvisor(true);
        }

        public DestinationFieldDragSourceAdvisor DragSource { get; set; }

        /// <summary>
        /// This is the actual field that is being mapped
        /// </summary>
        public FieldDefinition SrcField { get; set; }

        public DestinationFieldDropTargetAdvisor DropTarget { get; set; }

        /// <summary>
        /// Because this class wraps the <see cref="FieldDefinition"/> for the source field.  Return the name of the field for to string.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            if (SrcField != null)
                return SrcField.Name;

            return base.ToString();
        }
    }
}
